home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / ControlSocket.h < prev    next >
C/C++ Source or Header  |  2012-02-20  |  5KB  |  177 lines

  1. // FileZilla Server - a Windows ftp server
  2.  
  3. // Copyright (C) 2002-2004 - Tim Kosse <tim.kosse@gmx.de>
  4.  
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9.  
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. #if !defined(AFX_CONTROLSOCKET_H__17DD46FD_8A4A_4394_9F90_C14BA65F6BF6__INCLUDED_)
  20. #define AFX_CONTROLSOCKET_H__17DD46FD_8A4A_4394_9F90_C14BA65F6BF6__INCLUDED_
  21.  
  22. #if _MSC_VER > 1000
  23. #pragma once
  24. #endif // _MSC_VER > 1000
  25. // ControlSocket.h : Header-Datei
  26. //
  27.  
  28. #include "hash_thread.h"
  29.  
  30. class CAsyncGssSocketLayer;
  31. class CAsyncSslSocketLayer;
  32. class CTransferSocket;
  33.  
  34. #ifndef TRANSFERMODE_NOTSET
  35. #define TRANSFERMODE_NOTSET 0
  36. #endif
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // Befehlsziel CControlSocket
  40.  
  41. class CControlSocket : public CAsyncSocketEx
  42. {
  43. // Attribute
  44. public:
  45.  
  46. // Operationen
  47. public:
  48.     CControlSocket(CServerThread *pOwner);
  49.     virtual ~CControlSocket();
  50.  
  51. // ▄berschreibungen
  52. public:
  53.     CServerThread * m_pOwner;
  54.     CStdString m_RemoteIP;
  55.     void WaitGoOffline(bool wait = true);
  56.     BOOL m_bWaitGoOffline;
  57.     void CheckForTimeout();
  58.     void ForceClose(int nReason);
  59.     CTransferSocket* GetTransferSocket();
  60.     void ProcessTransferMsg();
  61.     void ParseCommand();
  62.     int m_userid;
  63.     BOOL Send(LPCTSTR str, bool sendStatus = true);
  64.     void SendStatus(LPCTSTR status,int type);
  65.     BOOL GetCommand(CStdString &command, CStdString &args);
  66.     bool InitImplicitSsl();
  67.  
  68.     virtual void OnReceive(int nErrorCode);
  69.     virtual void OnClose(int nErrorCode);
  70.     virtual void OnSend(int nErrorCode);
  71.     void AntiHammerIncrease(int amount = 1);
  72.  
  73.     void Continue();
  74.  
  75.     void ProcessHashResult(int hash_id, int res, CHashThread::_algorithm alg, const CStdString& hash, const CStdString& file);
  76.  
  77. // Implementierung
  78. protected:
  79.     BOOL DoUserLogin(LPCTSTR password, bool skipPass = false);
  80.     BOOL UnquoteArgs(CStdString &args);
  81.     static int GetUserCount(const CStdString &user);
  82.     static void IncUserCount(const CStdString &user);
  83.     static void DecUserCount(const CStdString &user);
  84.     void ResetTransferstatus();
  85.     BOOL CreateTransferSocket(CTransferSocket *pTransferSocket);
  86.     bool CheckIpForZlib();
  87.     void SendTransferinfoNotification(const char transfermode = TRANSFERMODE_NOTSET, const CStdString& physicalFile = "", const CStdString& logicalFile = "", __int64 startOffset = 0, __int64 totalSize = -1);
  88.     bool CanQuit();
  89.     CStdString GetPassiveIP();
  90.  
  91.     virtual int OnLayerCallback(std::list<t_callbackMsg>& callbacks);
  92.  
  93.     CAsyncGssSocketLayer *m_pGssLayer;
  94.     CAsyncSslSocketLayer *m_pSslLayer;
  95.  
  96.     std::list<CStdStringA> m_RecvLineBuffer;
  97.     char m_RecvBuffer[2048];
  98.     int m_nRecvBufferPos;
  99.     char *m_pSendBuffer;
  100.     int m_nSendBufferLen;
  101.  
  102.     int m_nTelnetSkip;
  103.     BOOL m_bQuitCommand;
  104.     SYSTEMTIME m_LastCmdTime, m_LastTransferTime, m_LoginTime;
  105.     static std::map<CStdString, int> m_UserCount;
  106.     CStdString m_CurrentServerDir;
  107.     static CCriticalSectionWrapper m_Sync;
  108.     struct t_status
  109.     {
  110.         BOOL loggedon;
  111.         CStdString user;
  112.         CStdString ip;
  113.  
  114.         int hammerValue;
  115.     } m_status;
  116.     struct t_transferstatus
  117.     {
  118.         int pasv;
  119.         _int64 rest;
  120.         int type;
  121.         CStdString ip;
  122.         int port;
  123.         CTransferSocket *socket;
  124.         bool usedResolvedIP;
  125.         int family;
  126.     } m_transferstatus;
  127.  
  128.     CStdString RenName;
  129.     BOOL bRenFile;
  130.  
  131.     enum TransferMode
  132.     {
  133.         mode_stream,
  134.         mode_zlib
  135.     };
  136.  
  137.     TransferMode m_transferMode;
  138.     int m_zlibLevel;
  139.  
  140.     int m_antiHammeringWaitTime;
  141.  
  142.     bool m_bProtP;
  143.  
  144.     bool m_useUTF8; // Enabled by default, can be turned off using
  145.                     // OPTS UF8 OFF
  146.  
  147.     void ParseMlstOpts(CStdString args);
  148.     void ParseHashOpts(CStdString args);
  149.  
  150.     // Enabled MLST facts
  151.     bool m_facts[4];
  152.  
  153.     bool m_shutdown;
  154.  
  155.     int m_hash_id;
  156.     
  157.     enum CHashThread::_algorithm m_hash_algorithm;
  158.  
  159. public:
  160.     long long GetSpeedLimit(enum sltype);
  161.  
  162.     typedef struct {
  163.         bool bContinue;
  164.         long long nBytesAllowedToTransfer;
  165.         long long nTransferred;
  166.         bool bBypassed;
  167.     } t_Quota;
  168.     t_Quota m_SlQuotas[2];
  169. };
  170.  
  171. /////////////////////////////////////////////////////////////////////////////
  172.  
  173. //{{AFX_INSERT_LOCATION}}
  174. // Microsoft Visual C++ fⁿgt unmittelbar vor der vorhergehenden Zeile zusΣtzliche Deklarationen ein.
  175.  
  176. #endif // AFX_CONTROLSOCKET_H__17DD46FD_8A4A_4394_9F90_C14BA65F6BF6__INCLUDED_
  177.